package com.socene.kotlin.bean

import org.springframework.data.domain.Example
import org.springframework.data.jpa.repository.JpaRepository
import java.io.Serializable


/* *
 *Created by: Sorata 2017/11/9 0009 上午 10:40
 *
 */
abstract class BaseService<T, ID : Serializable> {


    abstract val repository: JpaRepository<T, ID>

    fun save(entity: T) = repository.save(entity)

    fun save(entitys: Iterable<T>): MutableList<T> = repository.save(entitys)

    fun saveAndFlush(entity: T) = repository.saveAndFlush(entity)

    fun del(entity: T) = repository.delete(entity)

    fun del(id: ID) = repository.delete(id)

    fun del(ens: Iterable<T>) = repository.delete(ens)

    fun findOne(id: ID): T? = repository.findOne(id)

    fun findOne(example: Example<T>) = repository.findOne(example)

    fun exists(id: ID) = repository.exists(id)

    fun flush() = repository.flush()


}